package com.siysoft.tc.admin.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.siysoft.tc.admin.service.IAdminUserManageService;
import com.siysoft.util.IMap;


/**
 * <p>Title: AdminUserManageController</p>
 * <p>Description:用户管理功能</p>
 * <p>Company: dmpb</p>
 * @author    victor
 * @date       2015年11月12日
 */
@Controller
@RequestMapping(value = "/admin/user")
public class AdminUserManageController {
	@Autowired
	IAdminUserManageService adminUserManageService;
	
	
/*	//用户管理的首页
	@RequestMapping(value = "/index")
	public String index(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		List<Map<String,String>> seekUsers = userService.seekUsers(iMap);
		request.setAttribute("userList", seekUsers);
		return "/admin/user/index";
	}*/
	
	// 查询学生用户信息
		@RequestMapping(value = "/toStudents")
		public String toStudents(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			List<Map<String, String>> seekStudents = adminUserManageService.seekStudents(iMap);
			request.setAttribute("stuList", seekStudents);
			return "/admin/user/students";
		}

		// 跳转修改预约单信息页面
		@RequestMapping(value = "/toStuRevise")
		public String toStuRevise(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			Map<String, String> stuRevise = adminUserManageService.toStuRevise(iMap);
			request.setAttribute("stu", stuRevise);
			return "/admin/user/stuRevise";
		}

		// 修改预约单信息
		@RequestMapping(value = "/stuRevise")
		public String stuRevise(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			adminUserManageService.reviseStuInfo(iMap);
			return "redirect:/admin/user/toStudents.htm";
		}

		// 跳转教师管理页面
		@RequestMapping(value = "/toTeachers")
		public String toTeachers(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			List<Map<String, String>> seekTeachers = adminUserManageService.seekTeachers(iMap);
			request.setAttribute("teaList", seekTeachers);
			return "/admin/user/teachers";
		}

		// 跳转修改教师信息页面
		@RequestMapping(value = "/toTeaRevise")
		public String toTeaRevise(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			iMap.put("user_id", iMap.getInt("user_id"));
			Map<String, String> teaRevise = adminUserManageService.toTeaRevise(iMap);
			request.setAttribute("tea", teaRevise);
			return "/admin/user/teaRevise";
		}
		
		// 跳转修改推荐教师信息页面
		@RequestMapping(value = "/toRecommendTeaRevise")
		public String toRecommendTeaRevise(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			iMap.put("user_id", iMap.getInt("user_id"));
			Map<String, String> teaRevise = adminUserManageService.toRecommendTeaRevise(iMap);
			request.setAttribute("tea", teaRevise);
			return "/admin/user/recommendTeaRevise";
		}

		// 跳转教师查看详情页面
		@RequestMapping(value = "/toTeaDetail")
		public String toTeaDetailIndex(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			iMap.put("user_id", iMap.getInt("user_id"));
			Map<String, String> teaRevise = adminUserManageService.toTeaDetail(iMap);
			request.setAttribute("teaList", teaRevise);
			return "/admin/user/teaDetail";
		}
		
		// 跳转教师管理页面
		@RequestMapping(value = "/toRecommendTeachers")
		public String toRecommendTeachers(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			List<Map<String, String>> seekTeachers = adminUserManageService.seekRecommendTeachers(iMap);
			request.setAttribute("teaList", seekTeachers);
			return "/admin/user/recommendTeachers";
		}

		// TODO
		// 根据id删除教师信息并跳转教师信息页面
		@RequestMapping(value = "/toTeaDelete")
		public String toTeaDelete(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			iMap.put("user_id", iMap.getInt("user_id"));
			Map<String, String> teaRevise = adminUserManageService.toTeaDelete(iMap);
			request.setAttribute("msg", "se");
			return "redirect:/admin/user/toTeachers.htm";
		}

		// 修改教师信息
		@RequestMapping(value = "/teaRevise")
		public String teaUpdateInf(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			adminUserManageService.teaRevise(iMap);
			return "redirect:/admin/user/toTeachers.htm";
		}
		
		// 修改推荐的教师信息
		@RequestMapping(value = "/recommendTeaRevise")
		public String recommendTeaRevise(HttpServletRequest request) throws Exception {
			IMap iMap = new IMap(request);
			adminUserManageService.teaRevise(iMap);
			return "redirect:/admin/user/toRecommendTeachers.htm";
		}


	
	
}
